//引入接口的函数
import { ReqCategoryListData, reqGetBannerListData, reqGetFloorsistData } from "@/api"
const state = {
    categoryist: [],
    //轮博图数据
    bannerList: [],
    //楼层数据
    floorsList: []
};
const actions = {
    //获取三级分数的数据
    async getCategoryListData(context) {
        const result = await ReqCategoryListData();
        if (result.code === 200) {
            console.log(result.data)
            context.commit('GETCATEGORYLISTDATA', result)
        } else {
            console.log(result.message)
        }


    },
    //获取轮播图数据
    async getBannerListData({ commit }){
        const result1 = await reqGetBannerListData()
        if(result1.code == 200){
            commit ('SAVE_BANNER_LIST_DATA', result1.data)
    }

    },
    async getFloorsListData({commit}){
        const res=await reqGetFloorsistData()
        if(res.code==200){
            commit('SAVE_FLOORS_LIST_DATA',res.data )
        }
    }

    }









const mutations = {
    GETCATEGORYLISTDATA(state, payload) {
        state.categoryist = payload.data
    },
    SAVE_BANNER_LIST_DATA(state,bannerList){
        state.bannerList=bannerList
    },

    SAVE_FLOORS_LIST_DATA(state,floorsList) {
        state.floorsList=floorsList
    },

};
const getters = {

};
export default {
    namespaced: true,
    state,
    actions,
    mutations,
    getters,
}
